<?php
    require('common.php');
    
    $db = new Database();
    $user = getUser($db);
	
	if($user['group'] > 0) {
		redirect('index.php');
        exit();
	}
    
    $page = new HtmlPage();
    $page->writeHeader(lang('LOGIN_PAGENAME'));
    $page->write('<div class="content">', PUSH_TAB);
    $page->write('<h2>'.lang('LOGIN_PAGENAME').'</h2>');
    $page->write('<p>', PUSH_TAB);
    $page->write( lang('PLEASE_SIGNUP') );
    $page->write('</p>', POP_TAB);
    $page->write('<form action="dologin.php" method="post">', PUSH_TAB);
    if(isset($_GET['redirect']))
        $page->write('<input type="hidden" name="redirect" value="'.htmlEscape($_GET['redirect']).'"/>');
    else
        $page->write('<input type="hidden" name="redirect" value="index.php"/>');
    $page->write('<fieldset>', PUSH_TAB);
    $page->write('<legend>'.lang('LOGINDATA').'</legend>');
    $page->write('<div class="formentry even"><label><span>'.lang('USERNAME').' :</span><input type="text" name="user" /></label></div>');
    $page->write('<div class="formentry odd"><label><span>'.lang('PASSWORD').' :</span><input type="password" name="password" /></label></div>');
    $page->write('</fieldset>', POP_TAB);
    $page->write('<input type="submit" value="'.lang('LOGIN').'" />');
    $page->write('</form>', POP_TAB);
    $page->write('</div>', POP_TAB);
    $page->writeFooter();
?>
